from django.shortcuts import render,redirect
from django.core.paginator import Paginator
from .models import Product

def xiongkai(request):
    return redirect('/team/{}/'.format(1))

def team(request, type=1):

    types = ['西甲联赛', '英超联赛', '意甲联赛','德甲联赛','法甲联赛']
    result = Product.objects.filter(productType=type)
    # 分页操作
    paginator = Paginator(result,3)
    num = request.GET.get("num",1)
    page = paginator.page(num)

    return render(request, 'team.html', {'type': type, 'title':types[type - 1], 'data':page})

def team1detail(request,product_id):


    product = Product.objects.filter(id=product_id)
    code = 1
    if product :
        product = product[0]
    else:
        product = '没有查询到相关数据~'
        code = 0
    return render(request, 'team1detail.html', {'code':code , 'data': product})
